/**
 * 
 */
package sopia.sg;

import sopia.conn.DBAdapter;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.Spinner;

/**
 * @author tatsu@gmail.com
 *
 */
public class G002Activity extends Activity {

	/**
	 * 
	 */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.g002_layout);
		init();	
	}
	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
	  //Handle the back button
	  if (keyCode == KeyEvent.KEYCODE_BACK) {
		  Intent i = new Intent(G002Activity.this, G001Activity.class);
			i.putExtra("ID", "G002");
			startActivity(i);
			finish();
	    return true;
	  }

	  return super.onKeyDown(keyCode, event);
	} 
	private void init() {
		final Button forwardAddAccButton = (Button) findViewById(R.id.forward_addAcc_button);
		forwardAddAccButton.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				Intent i = new Intent(G002Activity.this, G003Activity.class);
				i.putExtra("ID", "G002");
//				i.putExtras(sendBundle);
				startActivity(i);

				// Giải phóng Activity1 khỏi Activity Stack vì ta sẽ ko quay lại
				// nó nữa
				finish();
			}
		});
		
		final Button forwardAddExpensiveButton = (Button) findViewById(R.id.forward_addExpensive_button);
		forwardAddExpensiveButton.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				Intent i = new Intent(G002Activity.this, G004Activity.class);
				i.putExtra("ID", "G002");
//				i.putExtras(sendBundle);
				startActivity(i);

				// Giải phóng Activity1 khỏi Activity Stack vì ta sẽ ko quay lại
				// nó nữa
				finish();
			}
		});
		
		final Button forwardAddItemExpensiveButton = (Button) findViewById(R.id.forward_addItemExpensive_button);
		forwardAddItemExpensiveButton.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				Intent i = new Intent(G002Activity.this, G005Activity.class);
				i.putExtra("ID", "G002");
//				i.putExtras(sendBundle);
				startActivity(i);

				// Giải phóng Activity1 khỏi Activity Stack vì ta sẽ ko quay lại
				// nó nữa
				finish();
			}
		});
		if(G001Activity.flagExistAccount || G003Activity.flagAdded){
			forwardAddExpensiveButton.setVisibility(0);
			forwardAddItemExpensiveButton.setVisibility(0);
		}else{
			forwardAddExpensiveButton.setVisibility(4);
			forwardAddItemExpensiveButton.setVisibility(4);
		}
	}

	
}
